home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kxmessages.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-09-10  |  6.2 KB  |  168 lines

  1. /****************************************************************************
  2.  
  3.  Copyright (C) 2001-2003 Lubos Lunak        <l.lunak@kde.org>
  4.  
  5. Permission is hereby granted, free of charge, to any person obtaining a
  6. copy of this software and associated documentation files (the "Software"),
  7. to deal in the Software without restriction, including without limitation
  8. the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. and/or sell copies of the Software, and to permit persons to whom the
  10. Software is furnished to do so, subject to the following conditions:
  11.  
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14.  
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  18. THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. DEALINGS IN THE SOFTWARE.
  22.  
  23. ****************************************************************************/
  24.  
  25. #ifndef __KXMESSAGES_H
  26. #define __KXMESSAGES_H
  27.  
  28. #include <qwidget.h>
  29. #include <qcstring.h>
  30. #include <qmap.h>
  31. #include <kdelibs_export.h>
  32. #ifdef Q_WS_X11
  33. #include <X11/X.h>
  34.  
  35. class QString;
  36.  
  37. class KXMessagesPrivate;
  38. /**
  39.  * Sending string messages to other applications using the X Client Messages.
  40.  *
  41.  * Used internally by KStartupInfo. You usually don't want to use this, use DCOP
  42.  * instead.
  43.  *
  44.  * @author Lubos Lunak <l.lunak@kde.org>
  45.  */
  46. // KDE4 - make this internal for KStartupInfo only?
  47. class KDECORE_EXPORT KXMessages
  48.     : public QWidget
  49.     {
  50.     Q_OBJECT
  51.     public:
  52.     /**
  53.      * Creates an instance which will receive X messages.
  54.      *
  55.      * @param accept_broadcast if non-NULL, all broadcast messages with 
  56.      *                         this message type will be received.
  57.      * @param parent the parent of this widget
  58.          * @param obsolete always set to false (needed for backwards compatibility
  59.          *                 with KDE3.1 and older)
  60.      */
  61.         KXMessages( const char* accept_broadcast, QWidget* parent, bool obsolete );
  62.         /**
  63.          * @deprecated
  64.          * This method is equivalent to the other constructor with obsolete = true.
  65.          */
  66.         KXMessages( const char* accept_broadcast = NULL, QWidget* parent = NULL );
  67.  
  68.         virtual ~KXMessages();
  69.     /**
  70.      * Sends the given message with the given message type only to given
  71.          * window.
  72.          * 
  73.          * @param w X11 handle for the destination window
  74.      * @param msg_type the type of the message
  75.      * @param message the message itself
  76.          * @param obsolete always set to false (needed for backwards compatibility
  77.          *                 with KDE3.1 and older)
  78.      */
  79.         void sendMessage( WId w, const char* msg_type, const QString& message,
  80.             bool obsolete );
  81.     /**
  82.          * @deprecated
  83.          * This method is equivalent to sendMessage() with obsolete = true.
  84.      */
  85.         void sendMessage( WId w, const char* msg_type, const QString& message );
  86.     /**
  87.      * Broadcasts the given message with the given message type.
  88.      * @param msg_type the type of the message
  89.      * @param message the message itself
  90.          * @param screen X11 screen to use, -1 for the default
  91.          * @param obsolete always set to false (needed for backwards compatibility
  92.          *                 with KDE3.1 and older)
  93.      */
  94.         void broadcastMessage( const char* msg_type, const QString& message,
  95.             int screen, bool obsolete );
  96.     /**
  97.          * @deprecated
  98.          * This method is equivalent to broadcastMessage() with obsolete = true.
  99.      */
  100.         void broadcastMessage( const char* msg_type, const QString& message );
  101.  
  102.     /**
  103.      * Sends the given message with the given message type only to given
  104.          * window.
  105.          * 
  106.      * @param disp X11 connection which will be used instead of 
  107.      *             qt_x11display()
  108.          * @param w X11 handle for the destination window
  109.      * @param msg_type the type of the message
  110.      * @param message the message itself
  111.          * @param obsolete always set to false (needed for backwards compatibility
  112.          *                 with KDE3.1 and older)
  113.      * @return false when an error occurred, true otherwise
  114.      */
  115.         static bool sendMessageX( Display* disp, WId w, const char* msg_type,
  116.             const QString& message, bool obsolete );
  117.     /**
  118.          * @deprecated
  119.          * This method is equivalent to sendMessageX() with obsolete = true.
  120.      */
  121.         static bool sendMessageX( Display* disp, WId w, const char* msg_type,
  122.             const QString& message );
  123.  
  124.     /**
  125.      * Broadcasts the given message with the given message type.
  126.      *
  127.      * @param disp X11 connection which will be used instead of 
  128.      *             qt_x11display()
  129.      * @param msg_type the type of the message
  130.      * @param message the message itself
  131.          * @param screen X11 screen to use, -1 for the default
  132.          * @param obsolete always set to false (needed for backwards compatibility
  133.          *                 with KDE3.1 and older)
  134.      * @return false when an error occurred, true otherwise
  135.      */
  136.         static bool broadcastMessageX( Display* disp, const char* msg_type,
  137.             const QString& message, int screen, bool obsolete );
  138.     /**
  139.          * @deprecated
  140.          * This method is equivalent to broadcastMessageX() with obsolete = true.
  141.      */
  142.         static bool broadcastMessageX( Display* disp, const char* msg_type,
  143.             const QString& message );
  144.     signals:
  145.     /**
  146.      * Emitted when a message was received.
  147.      * @param message the message that has been received
  148.      */
  149.         void gotMessage( const QString& message );
  150.     protected:
  151.     /**
  152.      * @internal
  153.      */
  154.         virtual bool x11Event( XEvent* ev );
  155.     private:
  156.         static void send_message_internal( WId w_P, const QString& msg_P, long mask_P,
  157.             Display* disp, Atom atom1_P, Atom atom2_P, Window handle_P );
  158.         QWidget* handle;
  159.         Atom accept_atom2;
  160.         QCString cached_atom_name_; // KDE4 unused
  161.         Atom accept_atom1;
  162.         QMap< WId, QCString > incoming_messages;
  163.         KXMessagesPrivate* d;
  164.     };
  165.  
  166. #endif
  167. #endif
  168.